#!/bin/sh 
# 
# script to bring up the tun device in QEMU in bridged mode 
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host - change to suit your host
#
# eth0 is on DHCP
# ETH0IP=192.168.0.3
# GATEWAY=192.168.0.1
# BROADCAST=192.168.0.255
#
# First take eth0 down, then bring it up with IP 0.0.0.0 
#
/sbin/ifdown eth0 2>&1
/sbin/ifconfig eth0 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
tunctl -t $1 -u `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
brctl addbr br0
brctl addif br0 eth0
brctl addif br0 $1
# 
# only a single bridge so loops are not possible, turn off spanning tree protocol
#
brctl stp br0 off 
# 
# Bring up the bridge with ETH0IP and add the default route 
#
# /sbin/ifconfig br0 $ETH0IP netmask 255.255.255.0 broadcast $BROADCAST
dhclient br0
route del default
route add default gw 164.99.136.254
#
# stop firewall - comment this out if you don't use Firestarter
#
# /sbin/service firestarter stop 

